Distributive Laws of Directed Containers

نویسندگان

  • Danel Ahman
  • Tarmo Uustalu
چکیده

Containers [1] are an elegant representation of a wide class of datatypes in terms of shapes and positions in shapes. In our FoSSaCS 2012 work [2], we introduced directed containers as a special case to account for the common situation where every position in a shape determines another shape, informally the subshape rooted by that position; some examples being the datatypes of nonempty lists and trees and the corresponding zipper datatypes. While containers interpret into set functors via a fully faithful monoidal functor, directed containers interpret into comonads. Further, it is also true that every comonad whose underlying functor is a container is represented by a directed container. In this paper, we develop a characterization of distributive laws between such comonads. A container S C P is given by a set S (of shapes) and a shape-indexed family P : S → Set (of positions). A morphism between containers S C P and S′ C P ′ is a pair t C q of maps t : S → S′ and q : Π{s : S}. P ′ (t s) → P s. (We use Agda’s syntax of braces for implicit arguments.) Containers form a category Cont carrying a monoidal structure defined by Id = 1 C λ ∗ . 1 and (S0 C P0) · (S1 C P1) = Σs : S0. P0 s → S1 C λ (s, v). Σp0 : P0 s. P1 (v p0) together suitable unital and associativity laws. The interpretation of a container S C P is the set functor given by JSCP KcX = Σs : S. P s→ X, JSCP Kc f (s, v) = (s, f ◦v). The interpretation of a container map tCq is the natural transformation JtCqKc(s, v) = (t s, v ◦q {s}). J−Kc is a fully faithful monoidal functor from Cont to [Set,Set]. A directed container is a container S C P together with three operations

برای دانلود رایگان متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

19th International Conference on Types for Proofs and Programs

We introduce update monads as a generalization of state monads. Update monads are thecompatible compositions of reader and writer monads given by a set and a monoid. Distributivelaws between such monads are given by actions of the monoid on the set.We also discuss a dependently typed generalization of update monads. Unlike simple updatemonads, they cannot be factored into a ...

متن کامل

Directed Containers as Categories

Directed containers make explicit the additional structure of those containers whose set functor interpretation carries a comonad structure. The data and laws of a directed container resemble those of a monoid, while the data and laws of a directed container morphism those of a monoid morphism in the reverse direction. With some reorganization, a directed container is the same as a small catego...

متن کامل

An Investigation of the Laws of Traversals

Traversals of data structures are ubiquitous in programming. Consequently, it is important to be able to characterise those structures that are traversable and understand their algebraic properties. Traversable functors have been characterised by McBride and Paterson as those equipped with a distributive law over arbitrary applicative functors; however, laws that fully capture the intuition beh...

متن کامل

Distributive laws in programming structures

Generalised Distributive laws in Computer Science are rules governing the transformation of one programming structure into another. In programming, they are programs satisfying certain formal conditions. Their importance has been to date documented in several isolated cases by diverse formal approaches. These applications have always meant leaps in understanding the nature of the subject. Howev...

متن کامل

Monad Compositions I: General Constructions and Recursive Distributive Laws

New techniques for constructing a distributive law of a monad over another are studied using submonads, quotient monads, product monads, recursively-defined distributive laws, and linear equations. Sequel papers will consider distributive laws in closed categories and will construct monad approximations for compositions which fail to be a monad.

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2012